package wms2010.gui.views.ageClass;

import java.awt.BorderLayout;
import java.awt.ComponentOrientation;
import java.awt.FlowLayout;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.AbstractTableModel;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import wms2010.controller.controller.IAgeClassController;
import wms2010.controller.controller.IDisciplineController;
import wms2010.gui.views.SimpleView;
import wms2010.gui.views.disciplines.DisciplineComboboxModel;
import wms2010.model.controller.model.AgeClass;
import wms2010.model.controller.model.Discipline;

@Component
public class AgeClassView extends SimpleView {
	@Autowired
	private IAgeClassController ageClassController;
	
	private JPanel details = new JPanel();
	private AgeClassViewTableModel tableModel = new AgeClassViewTableModel();
	private DisciplineViewTableModel discTableModel = new DisciplineViewTableModel();
	
	public AgeClassView() {
		this.init(tableModel, new ListSelectionListener() {

			public void valueChanged(ListSelectionEvent arg0) {
				discTableModel.setDisciplines(tableModel.getAgeClasses().get(data.getSelectedRow()).getDiscipline());
			} }, 2);
		JPanel toolbarDetails = new JPanel();
		
		JTable disciplineTable = new JTable(this.discTableModel);
		JScrollPane detailsScrollPane = new JScrollPane(disciplineTable);
		disciplineTable.setFillsViewportHeight(true);
		
		
		this.root.add(detailsScrollPane);
	}

	@Override
	public void show() {
		super.show();
		try {
			this.tableModel.setAgeClasses(this.ageClassController.getAllAgeClass());
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
